package edu.jiefengli.course_selection_system.mapper;

import edu.jiefengli.course_selection_system.pojo.entity.Course;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CourseMappper {
    @Insert("insert into course(name, credit, class_time, type, teacher_id, score) values(#{name}, #{credit}, #{classTime}, #{type}, #{teacherId}, 0)")
    void addCourse(Course course);

    @Select("select * from course where id = #{id}")
    Course getCourseById(int id);

    @Select("select * from course where teacher_id = #{teacherId}")
    List<Course> getCoursesByTeacherId(int teacherId);

    @Update("update course set name = #{name}, credit = #{credit}, class_time = #{classTime}, type = #{type}, teacher_id=#{teacherId} where id = #{id}")
    void updateCourse(Course course);

    @Select("select * from course")
    List<Course> getAllCourses();
}
